def check_brackets_sequence(sequence):
  stack = []

  opening = ['(', '[', '{', '<']
  closing = [')', ']', '}', '>']

  try:
    for bracket in sequence:
      if bracket in opening:
        stack.append(bracket)
      elif bracket in closing:
        if bracket != closing[opening.index(stack[-1])]:
          return False
        stack.pop()

    if len(stack) > 0:
      return False
  
    return True
  except:
    return False
    
inp = input()
print(check_brackets_sequence(inp))